# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Jerome Leclanche <jerome@leclan.ch>

_gemname=yard
pkgname=ruby-${_gemname}
pkgver=0.9.28
pkgrel=2
pkgdesc='YARD is a Ruby Documentation tool. The Y stands for "Yay!"'
url='https://yardoc.org/'
arch=('any')
license=('MIT')
depends=('ruby' 'ruby-rdoc' 'ruby-webrick')
makedepends=('ruby-rake' 'ruby-samus')
options=('!emptydirs')
source=(https://github.com/lsegal/yard/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('f57ce1f63ab1763729c85121cf1ac5927d4f7c53eed2fb58b1ea7d700db22481e767926845558d3db31bcef50d0181f0b6cf449e558a5548243256cdda0cd355')
b2sums=('7340f6815698ddb85aa16752266af75ecd3e1f1a5f328e147dd8ea01a750c48259e6f3413bb5d00777d4e983b340b36b21110e058cf6b326973c0a7c3d756836')

prepare() {
  cd ${_gemname}-${pkgver}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec
  sed 's|git ls-files|find|' -i ${_gemname}.gemspec
}

build() {
  cd ${_gemname}-${pkgver}
  rake gem
}

check() {
  cd ${_gemname}-${pkgver}
  rake spec
}

package() {
  cd ${_gemname}-${pkgver}
  local _gemdir="$(gem env gemdir)"
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "${pkgdir}/${_gemdir}" \
    --bindir "${pkgdir}/usr/bin" \
    ${_gemname}-${pkgver}.gem

  install -Dm 644 README.md CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  cp -a docs/* "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"

  cd "${pkgdir}/${_gemdir}"
  rm -rf cache gems/${_gemname}-${pkgver}/{ext,lib/*/*.so,man} \
    extensions/*/*/${_gemname}-${pkgver}/{mkmf.log,gem_make.out}
}

# vim: ts=2 sw=2 et:
